//
//  NetworkService.swift
//  RXSwiftTest
//
//  Created by ZhangBo on 2019/4/15.
//  Copyright © 2019 ZhangBo. All rights reserved.
//

import Foundation
import RxSwift
import RxCocoa

//网络请求服务
class NetworkService {

    //获取随机数据
    func getRandomResult() -> Driver<[String]> {
        print("正在请求数据......1")
        let items = (0..<15).map { _ in
            "随机数据\(Int(arc4random()))"
        }
        let observable = Observable.just(items)
        return observable.delay(1, scheduler: MainScheduler.instance)
            .asDriver(onErrorDriveWith: Driver.empty())
    }

    //获取随机数据
    func getRandomResult() -> Observable<[String]> {
        print("正在请求数据......2")
        let items = (0..<15).map { _ in
            "随机数据\(Int(arc4random()))"
        }
        let observable = Observable.just(items)
        return observable.delay(1, scheduler: MainScheduler.instance)
    }
}
